<template>
  <div>
    <div class="storage-card-box">
      <div class="title">{{ storageDetail.shop_info.shop_name }}</div>
      <div class="description">【存物单】</div>
      <div class="desc-item">
        <div>存物ID：</div>
        <span>{{ storageDetail.storage_id }}</span>
      </div>
      <div class="desc-item">
        <div>物品名称：</div>
        <span>{{ storageDetail.item_name }}</span>
      </div>
      <div class="desc-item">
        <div>数量：</div>
        <span>{{ storageDetail.num }}</span>
      </div>
      <div class="desc-item">
        <div>物主姓名：</div>
        <span>{{ storageDetail.user_name }}</span>
      </div>
      <div class="desc-item">
        <div>联系电话：</div>
        <span>{{ storageDetail.mobile }}</span>
      </div>
      <div class="desc-item">
        <div>存放时间：</div>
        <span>{{ storageDetail.create_time }}</span>
      </div>
      <div class="desc-item">
        <div>到期时间：</div>
        <span>{{ storageDetail.expire_time }}</span>
      </div>
      <div class="desc-item">
        <div>备注：</div>
        <span>{{ storageDetail.remark }}</span>
      </div>
      <div class="address-phone-box">
        <div>餐厅地址：{{ storageDetail.shop_info.address }}</div>
        <div>餐厅电话：{{ storageDetail.shop_info.phone }}</div>
        <div>技术支持：贵州一粒米科技餐饮软件服务有限公司</div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { onMounted, reactive, watch } from 'vue'
import { getStorageDetail } from '@/api/common'

const props = defineProps({
  templateSelection: { type: String, default: '' }
})

const storageDetail = reactive({ shop_info: {} })

watch(
  () => props.templateSelection,
  () => {
    getDetail()
  }
)

onMounted(() => {
  if (props.templateSelection) {
    getDetail()
  }
})

function getDetail() {
  if (!props.templateSelection) return
  getStorageDetail({ storage_id: props.templateSelection }).then(res => {
    Object.assign(storageDetail, res.data.detail || { shop_info: {} })
  })
}
</script>

<style lang="scss" scoped>
.storage-card-box {
  width: 420px;
  height: 1030px;
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 3px 0px 24px 0px rgba(0, 0, 0, 0.16);
  box-sizing: border-box;
  padding: 30px;
  .title {
    font-size: 20px;
    font-family: PingFang SC, PingFang SC-Bold;
    font-weight: 700;
    text-align: center;
    color: #333333;
  }
  .description {
    font-size: 16px;
    font-family: PingFang SC, PingFang SC-Bold;
    font-weight: 700;
    text-align: center;
    color: #333333;
    margin: 10px 0 20px 0;
  }
  .desc-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 14px;
    font-family: PingFang SC, PingFang SC-Bold;
    font-weight: 700;
    color: #333333;
    > div {
      width: 100px;
    }
    > span {
      display: block;
      flex: 1;
      text-align: right;
      line-height: 24px;
    }
  }
  .desc-line {
    width: 360px;
    height: 1px;
    background: #e2e2e2;
    margin-top: 10px;
  }
  .desc-title {
    font-size: 16px;
    font-family: PingFang SC, PingFang SC-Bold;
    font-weight: 700;
    text-align: center;
    color: #333333;
    margin: 20px 0 10px 0;
  }
  .address-phone-box {
    margin-top: 50px;
    font-size: 14px;
    font-family: PingFang SC, PingFang SC-Regular;
    font-weight: 400;
    text-align: center;
    color: #333333;
    line-height: 24px;
    > div {
      margin-bottom: 10px;
    }
  }
}
</style>
